package l1j.server.server.model.Instance;

import java.util.ArrayList;

import l1j.opqlo.NewSystem.Attack.L1AttackModel;
import l1j.opqlo.NewSystem.Attack.L1AttackPc;
import l1j.server.server.serverpackets.S_ChangeHeading;
import l1j.server.server.templates.L1Npc;
import l1j.server.server.utils.CalcExp;

public class L1ScarecrowInstance extends L1NpcInstance {

	private static final long serialVersionUID = 1L;

	public L1ScarecrowInstance(final L1Npc template) {
		super(template);
	}

	@Override
	public void onAction(final L1PcInstance player) {
		final L1AttackModel attack = new L1AttackPc(player, this);
		if (attack.calcHit()) {
			if (player.getLevel() < 5) { // ＬＶ制限もうける場合はここを変更
				final ArrayList<L1PcInstance> targetList = new ArrayList<L1PcInstance>();
				
				targetList.add(player);
				final ArrayList<Integer> hateList = new ArrayList<Integer>();
				hateList.add(1);
				CalcExp.calcExp(player, getId(), targetList, hateList, getExp());
			}
			if (getHeading() < 7) { // 今の向きを取得
				setHeading(getHeading() + 1); // 今の向きを設定
			} else {
				setHeading(0); // 今の向きが7 以上になると今の向きを0に戻す
			}
			broadcastPacketAll(new S_ChangeHeading(this)); // 向きの変更
		}
		attack.action();
	}

	@Override
	public void onTalkAction(final L1PcInstance l1pcinstance) {

	}

	public void onFinalAction() {

	}

	public void doFinalAction() {
	}
}
